﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;  
namespace hissql
{
    public partial class keshirenshu : Form
    {
        public keshirenshu()
        {
            InitializeComponent();
        }

        private void keshirenshu_Load(object sender, EventArgs e)
        {
            this.StartPosition = FormStartPosition.CenterParent;
        }

        private void lb_huanzhe_Click(object sender, EventArgs e)
        {
           
        }

        private void bt_chaxun_Click(object sender, EventArgs e)
        {
            SqlConnection sqlConnection = new SqlConnection();                              //声明并实例化SQL连接；
            sqlConnection.ConnectionString =
              // "Server=(local);Database=hissql;Integrated Security=sspi";             //在字符串变量中，描述连接字符串所需的服务器地址、数据库名称、集成安全性（即是否使用Windows验证）；
            "Server=SERVER-50;Integrated Security=False;database=hissql;uid=jsj;pwd=2wsx@WSX";    
            SqlCommand sqlCommand = new SqlCommand();                                       //声明并实例化SQL命令；
            sqlCommand.Connection = sqlConnection;                                          //将SQL命令的属性Connection指向SQL连接；
            sqlCommand.CommandText =                                                        //指定SQL命令的命令文本；命令文本由字符串拼接而成；
                "SELECT COUNT(1) FROM tb_Patient"
                + " WHERE Type='" +"01" +"'";
            sqlConnection.Open();                                                           //打开SQL连接；
            int rowCount = (int)sqlCommand.ExecuteScalar();                                 //调用SQL命令的方法ExecuteScalar来执行命令，并接受单个结果（即标量）；
            //执行标量的返回结果类型为object，可通过强制类型转换，转为整型；
           
           sqlCommand .CommandText ="SELECT COUNT(1) FROM tb_Doctor" + " WHERE DepartmentNo='" +"01" +"'";
           int rowCount1 = (int)sqlCommand.ExecuteScalar();

           sqlCommand.CommandText = "SELECT COUNT(1) FROM tb_Nurse" + " WHERE DepartmentNo='" + "01" + "'";
           int rowCount2 = (int)sqlCommand.ExecuteScalar();

           lb_huanzhe.Text = "患者：" + rowCount + "人" + "\n" + "医生：" + rowCount1 + "人" +"\n"+ "护士:" +" "+ rowCount2+ "人";
            sqlConnection.Close();                                                          //关闭SQ

           textBox1.Text = "   本科汇聚国内知名内科专家，结合较新技术，设备，打造了国内知名专业内科诊疗科室。科室与国际医疗水准接轨，对消化疾病专业、心脑血管疾病专业、神经内分泌专业、呼吸、泌尿专业等疾病的诊断和治疗方面积累了丰富的经验，对疑难杂症的研究方面也有较高的造诣。内科医护人员工作经验丰富，技术出色，坚持弘扬医德医风，为广大患者提供优质的健康服务，获得了广大患者的青睐和赞誉。";
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            EnterReg f = new EnterReg();
            f.Show();
            this.Close();

        }
    }
}
